package com.pcjavanet.generate;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;

public class FileUtil {

	/**
	 * @param args
	 */
	public static void main(String[] args) {

	}
	public static void targetMkdir(String fileFullPath	){
		if ( fileFullPath != null ){
			int lastIndex = fileFullPath.lastIndexOf( File.separator );
			String dirPath = fileFullPath.substring(0,lastIndex);
			File dir = new File(dirPath);
			if (!dir.exists()){
				dir.mkdirs();
			}
		}
	}
	public static void contentToSave(String path, String content) {
		try {
			targetMkdir( path  );
			File f = new File(path);
			if ( f.exists())
				f.delete();
			
			java.io.BufferedWriter bufwrite = new BufferedWriter(new FileWriter(path));
			bufwrite.write( content );
			bufwrite.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}